﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>测试容器</title>
    <script src="../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../Guide/Guide.js" type="text/javascript"></script>
    <script src="../../Scripts/layui/layui/layui.js" type="text/javascript"></script>

    <script src="../../Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
    <!--<link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />-->
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/html" />
    <link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <style id="theme-data"></style>
    <style>
        .top_title {
            height: 38px;
            line-height: 38px;
            border: 1px solid transparent;
            padding: 0 18px;
            background: #fff;
            color: #000;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border-radius: 2px;
            cursor: pointer;
        }

    </style>
    <script type="text/javascript">
        //页面启动函数.
        $(function () {

            $("#Btn_Reset").hide();

            $("#Msg").html("<img src=../../Img/loading.gif />&nbsp;正在加载可以<font color=red> 发起该流程 </font>的人员列表, 请稍后......");
            var doType = GetQueryString("DoType");
            if (doType == "" || doType == null)
                doType = "TestFlow2020_Init";

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString(doType);

            if (data.indexOf('err@') == 0) {
                if (data.indexOf('访问规则') > 0) {
                    $("#Msg").html('<font color=red>' + data + '</font>');
                    return;
                }

                if (data.indexOf('管理员') > 0) {
                    alert(data);
                    window.close();
                    SetHref('./../CCBPMDesigner/Login.htm');
                    return;
                }
                var msg = "<font color=red>" + data + "</font>";
                $("#Msg").html('<font color=red>' + msg + '</font>');
                return;
            }

            if (data.indexOf('url@') == 0) {
                if (data.indexOf('Login.htm') > 0) {
                    window.close();
                    return;
                }
                var url = data.replace('url@', '');
                SetHref(url);
                return;
            }

            //转化为Json.
            data = JSON.parse(data);

            if (data.length >= 3) {
                $("#more").hide();
            }

            //获得数据.
            layui.use(['table', 'util'], function () {
                var table = layui.table
                    , laydate = layui.laydate;

                //节点列表显示
                var vtable = table.render({
                    elem: '#TestFlow',
                    id: 'TestFlow',
                    data: data,
                    title: '数据表',
                    limit: Number.MAX_VALUE,
                    cellMinWidth: 120,
                    size: 'lg',
                    page: false,
                    cols: [[
                        {
                            field: '#', title: '序号', minWidth: 5,
                            templet: function (d) {
                                return '<div>' + d.LAY_TABLE_INDEX + '</div>';
                            }
                        }
                        , {
                            field: 'No', title: '用户', minWidth: 140,
                            templet: function (row) {
                                return "<a href=\"javascript:StartIt('" + row.No + "');\" ><i class='iconfont icon-Send'></i>" + row.No + " - " + row.Name + " </a>";
                            }
                        }
                        , { field: 'FK_DeptText', title: '部门', minWidth: 140 }
                        , {
                            field: 'Name', title: '测试容器', minWidth: 80,
                            templet: function (row) {
                                return "<a  href=\"javascript:StartHistory('" + row.No + "');\" ><i class='iconfont icon-Send'></i>历史记录</a>";
                            }
                        }
                    ]]
                });

            });

            if (data.length == 1) {
                $("#Btn_Reset").show();
            } else {
                $("#Btn_Reset").hide();
            }

            $("#Msg").html("");
        });
        function DFlow() {
            Flow();

            //var url = "../CCBPMDesigner/Designer.htm?FK_Flow=" + GetQueryString("FK_Flow") + "&UserNo=ccs&Token=null&OrgNo=ccs&From=Ver2021";
        }
    </script>
</head>
<body onkeypress="Esc()">

    <div class="layui-header" style="text-align: center;box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);background-color:white;height:48px">
        <div class="layui-btn-container" style="padding-top:10px">

            <!--<button type="button" class="layui-btn  layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="Accepter()">
        <i class="layui-icon">&#xe65a;</i>上一步：设置接收人
    </button>-->
            <!--<button type="button" class="layui-btn  layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="DFlow()">
        <i class="layui-icon">&#xe65a;</i>返回:设计器
    </button>-->
            <!--<button type="button" class="layui-btn  layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="Help()">
        <i class="layui-icon">&#xe607;</i>帮助
    </button>-->
            <!--<button type="button" class="layui-btn  layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="ToParaTest()">
        <i class="layui-icon">&#xe716;</i>参数测试
    </button>

    <button type="button" class="layui-btn  layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="SetTester()">
        <i class="layui-icon">&#xe609;</i>设置测试发起人
    </button>

    <button type="button" class="layui-btn  layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="FlowCheck()">
        <i class="layui-icon">&#xe65b;</i>检查流程
    </button>-->
            <div class="top_title">
                请选择发起流程的测试人员
            </div>

        </div>
    </div>

    <div class="container-full">
        <div class="layui-container">
            <div class="layui-card">
                <div class="layui-card-body">
                    <table class="layui-table" lay-filter="docs" id="TestFlow" style="width:70%"></table>
                    <div style="text-align: center;" id="more">
                        <button type="button" class="layui-btn layui-btn-normal layui-toolbar layui-btn-sm" data-type="MapDataEdit" onclick="ClearTester()()">
                            <i class="layui-icon" id="mor1e">&#xe65f;</i>显示更多
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <center>
            <div id="Info"></div>
            <div id="Msg"></div>
            <div id="Guide"></div>
        </center>
    </div>

    <script language="javascript" type="text/javascript">

        var fk_flow = GetQueryString('FK_Flow');
        var fk_node = GetQueryString('FK_Node');



        //检查流程.
        function FlowCheck() {

            var flowId = Number(flowNo);
            flowId = String(flowId);
            url = "../AttrFlow/CheckFlow.htm?FK_Flow=" + flowNo + "&FK_MapData=ND" + flowId + "MyRpt";
            OpenLayuiDialog(url, "检查流程", window.innerWidth * 0.9);
            return;
        }


        function StartClassic(userNo) {
            var url = "../TestFlow.htm?DoType=TestFlow_ReturnToUser&DoWhat=StartClassic&UserNo=" + userNo + "&FK_Flow=" + GetQueryString("FK_Flow");
            url += "&Token=" + GetQueryString("Token");
            url += "&OrgNo=" + GetQueryString("OrgNo");
            SetHref(url);
        }

        function closeTable(empNo) {
            $("#" + empNo).html('');
        }

        //历史记录.
        function StartHistory(empNo) {

            alert("已经取消该功能.");
            return;

            //获得当前用户发起的流程列表，并且没有完成的.
            var gwfs = new Entities("BP.WF.GenerWorkFlows");
            gwfs.Retrieve("Starter", empNo, "WFState", 2, "FK_Flow", GetQueryString("FK_Flow"), "WorkID DESC");

            //  var html = "<table style='width:900px;' >";
            var html = "<table class='table table-bordered table - hover' style='width:900px;' >";
            html += "<caption><a href=\"javascript:closeTable('" + empNo + "')\" >关闭</a></caption>";
            html += "<tr>";
            html += "<th>Idx</th>";
            html += "<th>WorkID</th>";
            html += "<th>标题</th>";
            html += "<th>停留节点</th>";
            html += "<th>当前人员</th>";
            html += "<th>发起日期</th>";
            html += "<th>最后处理日期</th>";
            html += "</tr>";

            for (var i = 0; i < gwfs.length; i++) {
                var en = gwfs[i];
                if (en.FID != 0) continue;

                html += "<tr>";
                html += "<td>" + i + "</td>";
                html += "<td>" + en.WorkID + "</td>";
                html += "<td><a href=\"javascript:StartIt('" + empNo + "','" + en.WorkID + "');\" >" + en.Title + "</a></td>";
                html += "<td>" + en.FK_Node + " - " + en.NodeName + "</td>";
                html += "<td>" + en.TodoEmps + "</td>";
                html += "<td>" + en.RDT + "</td>";
                html += "<td>" + en.SendDT + "</td>";
                html += "</tr>";
            }
            html += "</table>";

            $("#" + empNo).html(html);

        }

        //发起流程。
        function StartIt(empNo, workID) {

            var token = GetQueryString("Token") || GetQueryString("Token");
            if (!token || token == "null")
                token = localStorage.getItem("Token");
            var webUser = new WebUser();

            $("#Btn_Reset").val("正在以[" + empNo + "]启动流程,请稍候....");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddPara("FK_Flow", GetQueryString("FK_Flow"));
            handler.AddPara("TesterNo", empNo);
            handler.AddPara("UserNo", webUser.No);
            handler.AddPara("Token", token);
            handler.AddPara("OrgNo", webUser.OrgNo);

            var data = handler.DoMethodReturnString("TestFlow2020_StartIt");

            if (data.indexOf('访问规则') > 0) {
                alert(data);
                return;
            }

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (workID != undefined)
                data += "&WorkID=" + workID;

            //启动测试容器.
            //WinOpenFull(data);
            localStorage.setItem('AdminToken', token);
           
            //SetHref(data)
            WinOpenFull(data, "xx");    //打开全屏
        }

        function ClearTester() {

            $("#Btn_Reset").val("正在加载请稍候....");
            var en = new Entity("BP.WF.Template.FlowExt", GetQueryString("FK_Flow"));
            en.Tester = "";
            en.Update();
            Reload();
        }

        //设置可以发起的测试人员.
        function SetTester() {

            var webUser = new WebUser();
            var msg = "请输入测试人员的帐号，多个人员用逗号分开";
            msg += "\t\n 比如:zhangsan,lisi";
            msg += "\t\n 帐号就是登录该系统的编号，如果输入的帐号没有发起该流程的权限，系统就会提示错误。";
            var emps = promptGener(msg, webUser.No);

            var en = new Entity("BP.WF.Template.FlowExt", GetQueryString("FK_Flow"));
            en.Tester = emps;
            en.Update();
            Reload();
        }

        function ToParaTest() {

            alert("已经取消.");
            return;

            var url = "TestCase.htm?FK_Flow=" + GetQueryString("FK_Flow");
            SetHref(url);
            return;
        }
    </script>
    <script>
        $(function () {
            if (CustomerNo != "" && CustomerNo != null) {
                var styleScope = document.getElementById("theme-data");
                var html = "\n .layui-btn{\n background-color:'#5053f1';\n}\n .layui-laypage .layui-laypage-curr .layui-laypage-em{\n background-color:''#5053f1';\n}";
                html += "\n .layui-laypage input:focus,.layui-laypage select:focus{\n border-color:'#5053f1' !important\n}";
                html += "\n .layui-form-select dl dd.layui-this{\n background-color:'#5053f1' !important;\n}";

                styleScope.innerHTML = DealText(html);
                return;
            }

            var theme = DealText(localStorage.getItem("themeColorInfo"));
            if (theme == null || theme == undefined || theme == "")
                return;
            theme = JSON.parse(theme);
            var styleScope = document.getElementById("theme-data");
            var html = "\n .layui-btn{\n background-color:" + theme.selectedMenu + ";\n}\n .layui-laypage .layui-laypage-curr .layui-laypage-em{\n background-color:" + theme.selectedMenu + ";\n}";
            html += "\n .layui-laypage input:focus,.layui-laypage select:focus{\n border-color:" + theme.selectedMenu + " !important\n}";
            html += "\n .layui-form-select dl dd.layui-this{\n background-color:" + theme.selectedMenu + " !important;\n}";

            styleScope.innerHTML = DealText(html);
        })
    </script>
</body>
</html>
